package com.loyi.cloud.hbsystem.cqi.autoconfig;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.loyi.cloud.hbmis.api.IQueryService;
import com.loyi.cloud.hbsystem.cqi.utils.CQITotalService;

@Configuration
@EnableConfigurationProperties(value = { CQIConfigProperties.class })
public class CQIAutoConfiguration {

	@Autowired
	private CQIConfigProperties configProperties;
	
	@Autowired
	private IQueryService queryService;

	@Bean(destroyMethod="destroy")
	public CQITotalService cqiTotalService() {
		Map<String, Object> poll;
		List<Map<String, Object>> polls;
		CQITotalService totalService = new CQITotalService();
		polls = new ArrayList<Map<String, Object>>();

		poll = new HashMap<String, Object>();
		poll.put("pollcode", "448A");
		poll.put("othercode", "448A");
		poll.put("scope", "24");
		poll.put("mincount", "20");
		poll.put("name", "PM2.5");
		poll.put("intro", "24小时均值");
		poll.put("maxvalue", "1.5");
		poll.put("minvalue", "0.001");
		poll.put("rules", "0");
		poll.put("flag", "1");
		poll.put("must", "0");
		poll.put("radix", "0");
		polls.add(poll);

		poll = new HashMap<String, Object>();
		poll.put("pollcode", "4486");
		poll.put("othercode", "4486");
		poll.put("scope", "24");
		poll.put("mincount", "20");
		poll.put("name", "PM10");
		poll.put("intro", "24小时均值");
		poll.put("maxvalue", "3");
		poll.put("minvalue", "0.001");
		poll.put("rules", "0");
		poll.put("flag", "1");
		poll.put("must", "0");
		poll.put("radix", "0");
		polls.add(poll);

		poll = new HashMap<String, Object>();
		poll.put("pollcode", "4402");
		poll.put("othercode", "4402");
		poll.put("scope", "24");
		poll.put("mincount", "20");
		poll.put("name", "SO2");
		poll.put("intro", "24小时均值");
		poll.put("maxvalue", "2.62");
		poll.put("minvalue", "0.001");
		poll.put("rules", "0");
		poll.put("flag", "1");
		poll.put("must", "0");
		poll.put("radix", "0");
		polls.add(poll);

		poll = new HashMap<String, Object>();
		poll.put("pollcode", "4404");
		poll.put("othercode", "4404");
		poll.put("scope", "24");
		poll.put("mincount", "20");
		poll.put("name", "CO");
		poll.put("intro", "24小时均值");
		poll.put("maxvalue", "60");
		poll.put("minvalue", "0.001");
		poll.put("rules", "0");
		poll.put("flag", "1");
		poll.put("must", "0");
		poll.put("radix", "0");
		polls.add(poll);

		poll = new HashMap<String, Object>();
		poll.put("pollcode", "4467");
		poll.put("othercode", "4467");
		poll.put("scope", "24");
		poll.put("mincount", "20");
		poll.put("name", "NO2");
		poll.put("intro", "24小时均值");
		poll.put("maxvalue", "0.940");
		poll.put("minvalue", "0.001");
		poll.put("rules", "0");
		poll.put("flag", "1");
		poll.put("must", "0");
		poll.put("radix", "0");
		polls.add(poll);

		poll = new HashMap<String, Object>();
		poll.put("pollcode", "4D71");
		poll.put("othercode", "4D71");
		poll.put("scope", "17");
		poll.put("mincount", "10");
		poll.put("name", "O3-8h");
		poll.put("intro", "最大8小时滑动均值");
		poll.put("maxvalue", "2");
		poll.put("minvalue", "0.001");
		poll.put("rules", "1");
		poll.put("flag", "1");
		poll.put("must", "0");
		poll.put("radix", "0");
		polls.add(poll);
		
		totalService.setQueryService(queryService);
		totalService.setPolls(polls);
		
		return totalService;
	}

}
